#@layout()

#define content()

<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',border:true">
        <div id="datagridId"></div>

        <div id="datagridTb">
            <div class="row">
                <div class="col-md-12">
                    <form id="searchForm">
                        <div class="easyui-panel" title="信息查询" style="width:100%;padding:10px;"
                             data-options="iconCls:'icon-application_form'">

                            统计类型：
                            <select name="staType" id="staType" class="easyui-combobox" data-options="editable: false">
                                <option value="regCount" selected>注册</option>
                                <option value="verify">认证</option>
                                <option value="logoutCount">注销</option>
                            </select>
                            认证类型：
                            <select name="authType" id="authType" class="easyui-combobox" data-options="editable: false">
                                #for(dict : authTypeListForJS)
                                <option value="#(dict.dictText)">#(dict.dictName)</option>
                                #end
                            </select>
                            开始时间: <input class="easyui-datebox" id="startDate" data-options="required:true,editable:false"
                                         style="width:110px">&nbsp;&nbsp;
                            结束时间: <input class="easyui-datebox" id="endDate" data-options="required:true,editable:false"
                                         style="width:110px">&nbsp;&nbsp;
                            <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true"
                               onclick="datagridQuery();" iconCls="icon-zoom">#(_res.get('system.common.search'))</a>
                            <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true"
                               onclick="$('#searchForm').form('clear');" iconCls="icon-zoom_out">#(_res.get('system.common.clear'))</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>


</div>

#end


#define css()

#end


#define js()

<script type="text/javascript">

    var _datagrid = "datagridId", _form = "formId", _datagridTb = "datagridTb";
    var datagridListUrl = contextRootPath + '/dataStatistics/staDayList';

    $(function () {
        //初始化表格
        $("#" + _datagrid).datagrid({
            url: datagridListUrl,
            fit: true,
            border: false,
            rownumbers: true,
            pageSize: 20,
            toolbar: '#' + _datagridTb,
            singleSelect: false,
            pagination: true,
            nowrap: false,
            striped: true,
            fitColumns: true,
            queryParams: {
                'tenantId': $('#tenantId').val(),
                'staType': $('#staType').val(),
                'authType': $('#authType').val(),
                'startDate': $('#startDate').val(),
                'endDate': $('#endDate').val()
            },
            columns: [[
                {
                    field: DBConts.TABLE_DATA_STATISTICS.STA_TYPE,
                    title: "统计类型",
                    sortable: true,
                    formatter: function (value, row, index) {
                        if(value === 'regCount') return '注册';

                        if(value === 'verify') return '认证';

                        if(value === 'logoutCount') return '注销';
                    }
                },
                {
                    field: DBConts.TABLE_DATA_STATISTICS.AUTH_TYPE,
                    title: "认证类型",
                    sortable: true,
                    formatter: function (value, row, index) {
                        return getAuthType(value);
                    }
                },
                {
                    field: DBConts.TABLE_DATA_STATISTICS.STA_DATE,
                    title: "统计时间",
                    sortable: true
                },
                {
                    field: DBConts.TABLE_DATA_STATISTICS.STA_COUNT,
                    title: "统计数量",
                    sortable: true
                }
            ]]
        });
    });


    function datagridQuery() {
//        var flag = $("#searchForm").form('enableValidation').form('validate');
//
//        if (!flag) return;
        var startDate = $('#startDate').val();
        var endDate = $('#endDate').val();

        if(startDate === '' || startDate === null){
            $.messager.alert('警告','开始时间不能为空','warning');
            return;
        }

        if(endDate === '' || endDate === null){
            $.messager.alert('警告','结束时间不能为空','warning');
            return;
        }
        var starttime = new Date(Date.parse(startDate));
        var endtime = new Date(Date.parse(endDate));

        if(starttime > endtime){
            $.messager.alert('警告','时间不正确','warning');
            return;
        }

        $("#" + _datagrid).datagrid({
            queryParams: {
                'tenantId': $('#tenantId').val(),
                'staType': $('#staType').val(),
                'authType': $('#authType').val(),
                'startDate': $('#startDate').val(),
                'endDate': $('#endDate').val()
            }
        });
    }
</script>

#end



